package com.etl.plugin.datasource.admin;

import com.etl.base.DataSourceInfo;
import com.etl.plugin.datasource.pool.IBasePool;
import com.etl.plugin.datasource.pool.impl.MysqlConnectionPool;
import com.etl.plugin.datasource.pool.impl.OracleConnectionPool;

import java.util.List;

/**
 * 连接池工厂
 */
public class ConnPoolFactory {

     public void initConnPoll(List<DataSourceInfo> dataSourceInfos){
         dataSourceInfos.forEach(dataSourceInfo -> {
             switch (dataSourceInfo.getType()){
                 case "MYSQL":{
                     IBasePool mysqlConnectionPool = new MysqlConnectionPool();
                     mysqlConnectionPool.init(dataSourceInfo);
                     DataBasePoolContainer.put(dataSourceInfo.getId(),mysqlConnectionPool);
                     break;
                 }

                 case "ORACLE":{
                     OracleConnectionPool oracleConnectionPool = new OracleConnectionPool();
                     oracleConnectionPool.init(dataSourceInfo);
                     DataBasePoolContainer.put(dataSourceInfo.getId(),oracleConnectionPool);

                     break;
                 }

                 default:{

                 }

             }
         });

     }

}
